<?php

namespace App\Models\Rbac;

use App\Models\BaseModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Node extends BaseModel
{
    use HasFactory;
    //权限表
    protected $table="node";
    protected $fillable = [
        "name",
        "route",
        'description',
        "is_del",
        "created_at",
        "updated_at",
        "pid",
        "icon",
        "sort",
        "path",
        'is_menu',
        'component',
        'redirect'
    ];
    public function scopeSearch($query,$params)
    {
        if(!empty($params['name'])){
            $query->where('name',$params['name']);
        }
        $query->where('is_del',$params['is_del']??2);

        return $query;
    }
}
